﻿Imports System.Drawing

Public Class ControlScene
  Private _Rows As New List(Of ControlRow)

  Public ReadOnly Property Rows() As List(Of ControlRow)
    Get
      Return Me._Rows
    End Get
  End Property

  Public Sub DrawScene(ByVal g As Graphics, ByVal rect As Rectangle, ByVal dpifactor As Single, Optional ByVal drawRowOutline As Boolean = False, Optional ByVal drawButtonOutline As Boolean = False)
    Dim RowHeight As Integer = 120 * dpifactor
    Dim RowRect As New Rectangle(0, rect.Height - RowHeight, rect.Width, RowHeight)

    For Each Row As ControlRow In Me._Rows
      Row.DrawRow(g, RowRect, dpifactor, drawRowOutline, drawButtonOutline)
      RowRect = New Rectangle(0, RowRect.Top - RowHeight, rect.Width, RowHeight)
    Next
    If drawRowOutline OrElse drawButtonOutline Then
      Dim rectOutline As New Rectangle(rect.X, RowRect.Y + RowHeight, rect.Width - 1, (RowHeight * Me._Rows.Count) - 1)
      g.DrawRectangle(ControlButton.OutlinePen, rectOutline)
    End If
  End Sub

  Public Sub Clear()
    For Each s As ControlRow In Me._Rows
      s.Clear()
    Next
    Me._Rows.Clear()
  End Sub

  ''' <summary>
  ''' Returns a deep copy of this object.  The returned object will be logically identical to the source object, but will share no references.
  ''' </summary>
  Public Function Copy() As ControlScene
    Dim cs As New ControlScene
    For Each s As ControlRow In Me._Rows
      cs.Rows.Add(s.Copy)
    Next
    Return cs
  End Function
End Class
